import axios from 'axios'
import {appId, httptimeout} from '@/config/env'

export const apiGetFoodTypes = async (geohash) => {
  console.log("apiGetFoodTypes:", geohash);
  return axios.get('/v2/index_entry', {geohash: geohash, group_type: "1", "flags[]": 'F'});
}

export const apiGetShopList = async (latitude, longitude, offset, restaurant_category_id = '', restaurant_category_ids = '', order_by = '', delivery_mode = '', support_ids = []) => {
  let supportStr = '';
  support_ids.forEach(item => {
    if (item.status) {
      supportStr += '&support_ids[]=' + item.id;
    }
  });
  let data = {
    latitude,
    longitude,
    offset,
    limit: '20',
    'extras[]': 'activities',
    keyword: '',
    restaurant_category_id,
    'restaurant_category_ids[]': restaurant_category_ids,
     order_by,
    'delivery_mode[]': delivery_mode + supportStr
  };
  console.log("apiGetShopList:", data);
  return axios.get('/shopping/restaurants', {params: data});
}